﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;

namespace Kevin.Controls
{
    
    /// <summary>
    /// 枚举类型的使用方法
    /// </summary> 
    public enum EnumUsageTypes
    {
        /// <summary>
        /// 使用枚举类型的值(整型)
        /// </summary>
        UseEnumValue = 0,
        /// <summary>
        /// 使用枚举类型的字符串
        /// </summary>
        UseEnumString = 1,
    }
    public enum BindDirection
    {
        None = 0x00,
        DataToControl = 0x01,
        ControlToDdata = 0x10,
        Both = 0x11
    }
    [Serializable]
    [TypeConverter(typeof(DataBindItemCoverter))]
    public class DataBindItem
    {
        //*
        public Control TargetControl
        {
            get;
            set;
        }
        //*/
        string _propertyName;
        public string PropertyName
        {
            get { return _propertyName; }
            set { _propertyName = value.Trim(); }
        }

        string _controlPropertyName;
        public string ControlPropertyName
        {
            get { return _controlPropertyName; }
            set { _controlPropertyName = value.Trim(); }
        }

        string _customsRegexValidate="";
        /// <summary>
        /// 自定义正则表达式
        /// </summary>
        public string CustomsRegexValidate
        {
            get { return _customsRegexValidate; }
            set { _customsRegexValidate = value.Trim(); }
        }

        public string CustomsErrorMsg
        {
            get;
            set;
        }
        bool _doCustomsRegexValidate = true;
        /// <summary>
        /// 是否执行自定义表达式校验
        /// </summary>
        public bool DoCustomsRegexValidate
        {
            get { return _doCustomsRegexValidate; }
            set { _doCustomsRegexValidate = value; }
        }

        BindDirection _bindDirection=BindDirection.Both;
        [DefaultValue(BindDirection.Both)]
        public BindDirection BindDirection
        {
            get { return _bindDirection; }
            set { _bindDirection = value; }
        }

        public string DataFormat
        {
            get;
            set;
        }

        [Description("枚举类型绑定方式")]
        [DefaultValue(EnumUsageTypes.UseEnumValue)]
        public EnumUsageTypes EnumUsage
        {
            get;
            set;
        }
        [Description("枚举类型是否自动绑定")]
        [DefaultValue(true)]
        public bool EnumAutoBinding
        {
            get;
            set;
        }
    }

    internal class ValidateDefine
    {
        public string Regex
        {
            get;
            set;
        }
        public string ErrorMsg
        {
            get;
            set;
        }
    }
}
